<script src="${ctxPath}/static/js/lay/modules/element.js"></script>
<blockquote class="layui-elem-quote" style="font-size: 14px">兼职培训师积分规则

</blockquote>
<hr class="layui-bg-gray">
<form class="layui-form" action="" id="trainer_form">
    <div class="layui-collapse" lay-filter="trainer_collapse">
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">认证兼职培训师</h2>
            <div class="layui-colla-content layui-show">

                <table class="layui-table">
                    <colgroup>
                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="5%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addAuthenticationRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="authentication_table">
                    @for(cr in authenticationRules){
                    <tr>
                        <td><input type="text" name="authenticationRules[${crLP.index}].grade" value="${cr.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="authenticationRules[${crLP.index}].gradeCode" value="${cr.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="authenticationRules[${crLP.index}].integral" value="${cr.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">优秀兼职培训师</h2>
            <div class="layui-colla-content">


                <table class="layui-table">
                    <colgroup>

                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="1%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addExcellentRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="excellent_table">
                    @for(sgr in excellentRules){
                    <tr>
                        <td><input type="text" name="excellentRules[${sgrLP.index}].grade" value="${sgr.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="excellentRules[${sgrLP.index}].gradeCode" value="${sgr.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="excellentRules[${sgrLP.index}].integral" value="${sgr.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">项目制兼职培训师</h2>
            <div class="layui-colla-content">

                <table class="layui-table">
                    <colgroup>

                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="1%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addProjectRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="project_table">
                    @for(pr in projectRules){
                    <tr>
                        <td><input type="text" name="projectRules[${prLP.index}].grade" value="${pr.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="projectRules[${prLP.index}].gradeCode" value="${pr.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="projectRules[${prLP.index}].integral" value="${pr.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">周期制兼职培训师</h2>
            <div class="layui-colla-content">

                <table class="layui-table">
                    <colgroup>

                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="1%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addCycleRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="city_table">
                    @for(city in cycleRules){
                    <tr>
                        <td><input type="text" name="cycleRules[${cityLP.index}].grade" value="${city.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="cycleRules[${cityLP.index}].gradeCode" value="${city.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="cycleRules[${cityLP.index}].integral" value="${city.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" style="margin-top: 20px;">

            <button class="layui-btn" lay-submit lay-filter="trainer_form" >提交保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<template>
    <tr>
        <td><input type="text" name="[].grade" autocomplete="off" class="layui-input" lay-verify="required"></td>
        <td><input type="text" name="[].gradeCode" autocomplete="off" class="layui-input" lay-verify="required"></td>
        <td><input type="text" name="[].integral" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
        <td>
            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                <i class="fa fa-trash-o"></i>
            </button>
        </td>
    </tr>
</template>
<script>
    $(function(){
        initFullTimeTrain();
    });

    function initFullTimeTrain() {
        layui.use(['layer', 'form'], function(){
            var element = layui.element;
            var layer = layui.layer;
            var form = layui.form;

            //监听折叠
            element.on('collapse(trainer_collapse)', function(data){

            });

            form.on('submit(trainer_form)', function(data){
                form.verify();
                $.ajax({
                    type: "POST",
                    url: 'integral/part_time_trainer_add',
                    data: data.field,
                    dataType: "json",
                    success: function(data){
                        Feng.success("保存成功!");
                    }
                });
                return false;
            });
        });

    }


    function deleteRow($this) {
        $this.closest("tr").empty();
    }


    /**
     * 经营添加行
     */
    function addAuthenticationRow() {
        var trSize = $("#authentication_table>tr").length + 1;
        $("#authentication_table").append($("template").html().replace(/\[]/g,"authenticationRules["+trSize+"]"));
    }

    /**
     * 管理添加行
     */
    function addExcellentRow() {
        var trSize = $("#excellent_table>tr").length + 1;
        $("#excellent_table").append($("template").html().replace(/\[]/g,"excellentRules["+trSize+"]"));
    }

    /**
     * 技术人员
     */
    function addProjectRow() {
        var trSize = $("#project_table>tr").length + 1;
        $("#project_table").append($("template").html().replace(/\[]/g,"projectRules["+trSize+"]"));
    }

    /**
     * 技能人员
     */
    function addCycleRow() {
        var trSize = $("#city_table>tr").length + 1;
        $("#city_table").append($("template").html().replace(/\[]/g,"cycleRules["+trSize+"]"));
    }


</script>
